layui.use(['form','layer','table','laytpl','upload'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        laytpl = layui.laytpl,
        upload = layui.upload, //得到 upload 对象
        table = layui.table;

    upload.render({
        elem: '.expStu_file_btn'
        //,url: '/stuExpFile' //必填项
        ,url: '/stuExpFileAndDr'
        //,data: {} //可选项。额外的参数，如：{id: 123, abc: 'xxx'}
        ,accept: 'file' //允许上传的文件类型
        ,exts:'xls|xlsx'
        ,size: 10240 //最大允许上传的文件大小
        ,done: function(res,index,upload){
            if(res.msg=='success'){
                layer.msg("导入成功。");
            }else if(res.msg=='error'){
                layer.msg("导入失败。");
            }else{
                layer.msg(res.msg);
            }

        }
        ,error: function(){
            layer.msg("文件上传失败.");
        }
    });

    //上传提交
    $(".expStu_submit_btn").click(function(){
        location.href = "/testmob";
    });

    //下载文件
    $(".expStu_down_btn").click(function(){
        location.href="/stuDownFile";
    });


    //列表
    /*var tableIns = table.render({
        elem: '#studentExpList',
        url : '/studentExpList',
        cellMinWidth : 95,
        page : true,
        height : "full-125",
        limits : [10,15,20,25],
        limit : 20,
        id : "studentExpListTable",
        cols : [[
            {field: 'bjmc', title: '学校名称', minWidth:80, align:'center'},
            {field: 'bjmc', title: '班级名称', minWidth:80, align:'center'},
            {field: 'name', title: '学生姓名', minWidth:60, align:"center"},
            {field: 'sfz', title: '身份证', minWidth:80, align:'center'},
            {field: 'xjfh', title: '学籍辅号', minWidth:80, align:'center'},
            {field: 'bjmc', title: '性别', minWidth:80, align:'center'}
        ]]
    });*/

    document.onkeydown = function(e){
        var ev = document.all ? window.event : e;
        if(ev.keyCode==13) {
            table.reload("studentExpListTable",{
                url:"/studentExpList",
                page: {
                    curr: 1 //重新从第 1 页开始
                },
                where: {
                    username: $(".searchVal").val()  //搜索的关键字
                }
            })
        }
    }
})
